<?php
include('jxc_inc_head.php');
$id=$wu->request_int('id');
$data=to_array_keys('Name','CatalogID','Description','Thumb','Barcode');
if($id){
	$data=$db->fetch_row("select * from tproductgoods where ID=$id");
}
if($wu->request_string("act")=='save'){
	$m=new module('tproductlog');
	$this->dm->data('Barcode','string',$data['Barcode']);
	$this->dm->data('ProductID','int',$id);	
	$this->dm->data('InOrOut','string','in');
	$dm->param('Quantity','int','数量未填写');
	$dm->param('Price','int','价格未填写');
	$dm->param('Amount','int','金额未填写');
	$dm->param('Remark','string');	
	$dm->param('ProviderID','int','供应商未选择');
	$dm->param('UserName','string','采购员未选择');
	$dm->param('OperateTime','datetime','进货日期无效');
	$this->dm->data('OperateID','int',3);
	$this->dm->data('Stock','int',$data['Stock']+$this->dm->Quantity);
	$result=false;
	if($this->dm->insert()){
		$result=$db->update('tproductgoods','Stock='.$this->dm->Stock,'ID='.$id);
	}
	$wu->redirect($result?'新增成功':$this->dm->get_error(),'productlog_list.php');
}
?>
<div class="location"><?php echo $wu->location_links(array('商品列表'=>'product_list.php?tag='.$data['ExTags'],'编辑库存'=>'#')); ?></div>
<form action="#" method="post" >
    <table>
    	<tr><td>条码</td><td><?php echo $data['Barcode']; ?></td></tr>
        <tr><td>名称</td><td><?php echo $data['Name']; ?></td></tr>
        <tr><td>库存</td><td><?php echo $data['Stock']; ?></td></tr>
        <tr><td>进货价格</td><td><input type="text" name="Price" size="12" /></td></tr>
        <tr><td>进货数量</td><td><input type="text" name="Quantity" size="12" /></td></tr>
        <tr><td>进货金额</td><td><input type="text" name="Amount" size="12" /></td></tr>
        <tr><td>采购日期</td><td><input type="text" name="OperateTime" class="date" value="<?php echo date('Y-m-d'); ?>" size="12" /></td></tr>
        <tr><td>采购员姓名</td><td><select name="UserName"><?php echo get_list_option('select UserName,Name from tusermember where Name is not null',''); ?></select> <a href="../../WADS/Admin/Wap/member_edit.php" target="_blank">新增</a></td></tr>
        <tr><td>批发商名称</td><td><select name="ProviderID"><?php echo $biz->get_generaltree(0,'tgeneraldata','provider'); ?></select> <a href="../../WADS/Admin/Wap/generaldata_edit.php?tag=provider" target="_blank">新增</a></td></tr>
        <tr><td>备注</td><td><textarea name="Remark" cols="120" rows="15" class="editor"></textarea></td></tr>
        <tr><td colspan="2"><input type="submit" value="保存" /><input type="reset" class="btn" value="重置" /></td></tr>
    </table>
    <input type="hidden" name="act" value="save" />
</form>
<?php
	include('jxc_inc_foot.php');
?>